home *** CD-ROM | disk | FTP | other *** search
- unit Test;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls;
-
- type
- TForm1 = class(TForm)
- Edit1: TEdit;
- Button1: TButton;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure ShowMessage(inputText : string );
- { Display a message with a '!' (mtInformation and OK button }
- begin
- MessageDlg(inputText, mtInformation,[mbOK] , 0);
- end;
-
- function MakeMessage(msg: string): string;
- { Return a string including msg parameter }
- begin
- MakeMessage := 'You entered: ' + msg + '!' ;
- end;
-
-
- procedure TForm1.Button1Click(Sender: TObject);
- { This procedure examines the Edit1 text box. If it
- contains the text, 'Hello world', the user is congratulated.
- Otherwise, the user is asked to try agan. }
- Const
- FormName = 'Test Form';
- Var
- SomeText : string;
- a_message : string;
- begin
- SomeText := Edit1.Text;
- if SomeText = 'Hello world' Then
- Form1.Caption := FormName + ' Success!'
- else
- begin
- Edit1.Text := 'Please try again';
- Form1.Caption := FormName + ' Failure!'
- end;
- a_message := MakeMessage(SomeText);
- ShowMessage(a_message);
- end;
-
- end.
-